package com.wjboot.system.controller;

import com.wjboot.common.util.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @description:
 * @author: 周振林
 * @date: 2022-11-27
 * @website: http://www.zhouzhenlin.com - 沉淀、分享、成长、让自己和他人都有所收获
 **/

@Slf4j
@RestController
@RequestMapping("/api/test")
@Tag(name = "测试")
public class TestController {

    @GetMapping("/{id}")
    @Operation(summary = "id")
    public Object pathVari(@PathVariable("id") Integer id){
        log.info(id.toString());
        return R.ok();

    }

    @GetMapping("")
    @Operation(summary = " ")
    public Object getBy(String name, String type){
        log.info(name);
        log.info(type);

        return R.ok();
    }

    @PostMapping("/x-www")
    @Operation(summary = "x-www")
    public Object getByUrl(@RequestParam String name, @RequestParam String pwd){
        log.info(name);
        log.info(pwd);

        Map<String,String> map=new HashMap<String,String>();
        map.put("name",name);
        map.put("pwd",pwd);

        return R.ok(map);
    }

    @GetMapping("/json")
    @Operation(summary = "json")
    public Object getByJson(@RequestBody TestDto testDto){
        log.info(testDto.getName());
        log.info(testDto.getPwd());

        Map<String,String> map=new HashMap<String,String>();
        map.put("name",testDto.getName());
        map.put("pwd",testDto.getPwd());

        return R.ok(map);
    }

    public Object get_obj(){

        return R.ok();
    }

}
